﻿using System.Web;
using ErrorDumper.PropertyExtracting;

namespace ErrorDumper.Web.PropertyBinders {
    public class HttpExceptionPropertyBinder : IExceptionPropertyExtractor {
        public void ExtractProperties(
            ref ExceptionPropertyCollection properties, object instance) {
            
            var exception = instance as HttpException;
            if (exception == null)
                return;
            
            if (properties == null)
                properties = new ExceptionPropertyCollection();
            if (!properties.Contains("HttpErrorCode"))
                properties["HttpErrorCode"] = exception.ErrorCode.ToString();
        }
    }
}